Simplify GtkColorScale private api a bit
authorMatthias Clasen <mclasen@redhat.com>
Fri, 3 Feb 2012 17:13:06 +0000 (12:13 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 14 Feb 2012 21:36:55 +0000 (16:36 -0500)
gtk/gtkcoloreditor.c
gtk/gtkcolorscale.c
gtk/gtkcolorscale.h

index 99e3c534aefb71e1e29a2b6fd467f776b7d5c911..1e5146c64fcfdb580c445ceb70ee980e0d1aed3c 100644 (file)
@@ -396,23 +396,17 @@ gtk_color_editor_init (GtkColorEditor *editor)
   g_signal_connect (editor->priv->entry, "focus-out-event",
                     G_CALLBACK (entry_focus_out), editor);
 
-  editor->priv->h_slider = slider = g_object_new (GTK_TYPE_COLOR_SCALE,
-                                                  "adjustment", editor->priv->h_adj,
-                                                  "draw-value", FALSE,
-                                                  "orientation", GTK_ORIENTATION_VERTICAL,
-                                                  NULL);
-  gtk_color_scale_set_type (GTK_COLOR_SCALE (slider), GTK_COLOR_SCALE_HUE);
+  editor->priv->h_slider = slider = gtk_color_scale_new (editor->priv->h_adj,
+                                                         GTK_COLOR_SCALE_HUE);
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (slider), GTK_ORIENTATION_VERTICAL);
   if (gtk_widget_get_direction (slider) == GTK_TEXT_DIR_RTL)
     gtk_style_context_add_class (gtk_widget_get_style_context (slider), GTK_STYLE_CLASS_SCALE_HAS_MARKS_ABOVE);
   else
     gtk_style_context_add_class (gtk_widget_get_style_context (slider), GTK_STYLE_CLASS_SCALE_HAS_MARKS_BELOW);
 
-  editor->priv->a_slider = slider = g_object_new (GTK_TYPE_COLOR_SCALE,
-                                                  "adjustment", editor->priv->a_adj,
-                                                  "draw-value", FALSE,
-                                                  "orientation", GTK_ORIENTATION_HORIZONTAL,
-                                                  NULL);
-  gtk_color_scale_set_type (GTK_COLOR_SCALE (slider), GTK_COLOR_SCALE_ALPHA);
+  editor->priv->a_slider = slider = gtk_color_scale_new (editor->priv->a_adj,
+                                                         GTK_COLOR_SCALE_ALPHA);
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (slider), GTK_ORIENTATION_HORIZONTAL);
   gtk_style_context_add_class (gtk_widget_get_style_context (slider), GTK_STYLE_CLASS_SCALE_HAS_MARKS_ABOVE);
 
   editor->priv->sv_plane = gtk_color_plane_new (editor->priv->h_adj,
index 9e8401ea26e8af9677defa8ebd307067541383e5..a5cbae58f37a30643b0e76f3bb5f02700a507b63 100644 (file)
@@ -309,7 +309,7 @@ gtk_color_scale_set_color (GtkColorScale *scale,
   gtk_widget_queue_draw (GTK_WIDGET (scale));
 }
 
-void
+static void
 gtk_color_scale_set_type (GtkColorScale     *scale,
                           GtkColorScaleType  type)
 {
@@ -333,10 +333,16 @@ gtk_color_scale_set_type (GtkColorScale     *scale,
 }
 
 GtkWidget *
-gtk_color_scale_new (void)
+gtk_color_scale_new (GtkAdjustment     *adjustment,
+                     GtkColorScaleType  type)
 {
-  return (GtkWidget *) g_object_new (GTK_TYPE_COLOR_SCALE,
-                                     "adjustment", gtk_adjustment_new (0, 0, 1, 0.01, 0.1, 0),
-                                     "draw-value", FALSE,
-                                     NULL);
+  GtkWidget *scale;
+
+  scale = (GtkWidget *) g_object_new (GTK_TYPE_COLOR_SCALE,
+                                      "adjustment", adjustment,
+                                      "draw-value", FALSE,
+                                      NULL);
+  gtk_color_scale_set_type (GTK_COLOR_SCALE (scale), type);
+
+  return scale;
 }
index f5d28ba993c9cf41ab538c1aeaa0b6a2ba67b6fc..767b01012cb6333c730e9fed1a9aea9916836507 100644 (file)
@@ -68,10 +68,9 @@ G_GNUC_INTERNAL
 GType       gtk_color_scale_get_type  (void) G_GNUC_CONST;
 
 G_GNUC_INTERNAL
-GtkWidget * gtk_color_scale_new       (void);
-G_GNUC_INTERNAL
-void        gtk_color_scale_set_type  (GtkColorScale     *scale,
+GtkWidget * gtk_color_scale_new       (GtkAdjustment     *adjustment,
                                        GtkColorScaleType  type);
+
 G_GNUC_INTERNAL
 void        gtk_color_scale_set_color (GtkColorScale     *scale,
                                        const GdkRGBA     *color);